package gui;

import java.util.Timer;
import java.util.TimerTask;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.Sprite;

import logic.LogicHelper;

/**
 * waiting screen when server waits for clients
 * @author Rekin
 *
 */
public class ServerConnectingToClientWaitingScreen extends Canvas{
	private Sprite loadingSprite;
	private Timer iTimer;
	
	/**
	 * default constructor
	 */
	public ServerConnectingToClientWaitingScreen(){
		loadingSprite = new Sprite(LogicHelper.createImageFromResources("/loading_server.png", this),
				50,50);
		loadingSprite.setPosition(getWidth()/2-25, getHeight()/2-25);
		iTimer = new Timer();
		iTimer.schedule(new TimerTask(){
			public void run(){
				repaint();
				loadingSprite.nextFrame(); //it automatically jumps to start of sequence
				} 
			} , 0, 80);
	}
	
	/**
	 * paintings
	 */
	protected void paint(Graphics g) {
		g.setColor(0x000000);
		g.drawRect(0, 0, getWidth(), getHeight());
		loadingSprite.paint(g);
	}
}
